<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$router->get('/', function () use ($router) {
    //return $router->app->version();
    echo $_SERVER['REQUEST_URI'];
    if (strpos($_SERVER['REQUEST_URI'], '/h5') == true) {
        return redirect('/h5/index.html?code=' . $_GET['code']);
    }
    return '不给你看';
});


//后台管理API
$router->group(['prefix'=>'/api/admin', 'namespace'=>'Admin'], function () use ($router) {
//    $router->post('dologin', 'IndexController@dologin');
    $router->post('cate/list', 'CateController@index');
    $router->post('cate/modify', 'CateController@modify');
    $router->post('cate/del', 'CateController@del');
    $router->post('banner/list', 'BannerController@index');
    $router->post('banner/modify', 'BannerController@modify');
    $router->post('banner/del', 'BannerController@del');
    $router->post('xcx/list', 'XcxController@index');
    $router->post('xcx/modify', 'XcxController@modify');
    $router->post('xcx/enable/one', 'XcxController@enableOne');
    $router->post('xcx/enable/modify', 'XcxController@setEnable');
    $router->post('visit/list', 'UserController@visitList');
    $router->post('wx/list', 'UserController@wxList');
    $router->post('qr/list', 'QrController@index');
    $router->post('qr/add', 'QrController@add');
    $router->post('qrlog/list', 'QrController@log');
    $router->post('shequ/index', 'ShequController@index');
    $router->post('shequ/modify', 'ShequController@modify');
    $router->post('shequ/del', 'ShequController@del');
    $router->post('shequ/arealist', 'ShequController@areaList');
    $router->group(['prefix'=>'yw-user', 'namespace'=>'Ywuser'], function () use ($router) {
        $router->post('tmp/list', 'TmpController@index');
        $router->post('tmp/modify', 'TmpController@modify');
        $router->post('tmp/del', 'TmpController@del');
        $router->post('tmp/option', 'TmpController@option');
    });
    $router->group(['prefix'=>'address'], function () use ($router) {
        $router->post('list', 'AddressController@index');
        $router->post('modify', 'AddressController@modify');
        $router->post('todefault', 'AddressController@toDefault');
        $router->post('del', 'AddressController@del');
    });
    $router->group(['prefix'=>'yw-mall', 'namespace'=>'Ywmall'], function () use ($router) {
        $router->post('shop/list', 'ShopController@index');
        $router->post('shop/modify', 'ShopController@modify');
        $router->post('shop/del', 'ShopController@del');
        $router->post('goods/list', 'GoodsController@index');
        $router->post('goods/modify', 'GoodsController@modify');
        $router->post('goods/del', 'GoodsController@del');
        $router->post('fuwu/list', 'FuwuController@index');
        $router->post('fuwu/modify', 'FuwuController@modify');
        $router->post('fuwu/del', 'FuwuController@del');
    });
});


//H5接口
$router->group(['prefix'=>'/api/h5', 'namespace'=>'H5'], function () use ($router) {
    $router->post('index', 'IndexController@index');
    $router->post('one', 'IndexController@one');
    $router->post('ad/read', 'IndexController@adRead');
    $router->post('toxcx', 'IndexController@toxcx');
});


//小程序接口
$router->group(['prefix'=>'/api/xcx', 'namespace'=>'Xcx'], function () use ($router) {
    $router->post('wxauth/one', 'IndexController@wxOne');
    $router->post('wxauth/modify', 'IndexController@wxModify');
    $router->post('wxauth/head', 'IndexController@wxHead');
    $router->post('init', 'IndexController@init');
    $router->post('banner/list', 'IndexController@banner');
    $router->post('shequ/list', 'IndexController@shequList');
    $router->post('cate/list', 'IndexController@cateList');
    $router->post('cate/plist', 'IndexController@catePid');
//    $router->post('cate/child', 'IndexController@cateChild');
    //$router->post('my/index', 'IndexController@my');
    $router->post('scan/code/one', 'IndexController@codeOne');
    $router->post('scan/img/upload', 'IndexController@imgUpload');
    $router->post('my/tongji', 'IndexController@myTongji');
    $router->group(['prefix'=>'yw-user', 'namespace'=>'Ywuser'], function () use ($router) {
        $router->post('tmp/list', 'TmpController@index');
        $router->post('tmp/one', 'TmpController@one');
        $router->post('tmp/onebyid', 'TmpController@onebyid');
        $router->post('tmp/onebyserial', 'TmpController@onebyserial');
        $router->post('tmp/add', 'TmpController@add');
        $router->post('tmp/modify', 'TmpController@modify');
        $router->post('tmp/img/upload', 'TmpController@imgUpload');
        $router->post('tmp/cate/list', 'TmpController@cateList');
        $router->post('tmp/cate/edit', 'TmpController@cateEdit');
        $router->post('tmp/attr/list', 'TmpController@attrList');
        $router->post('tmp/attr/edit', 'TmpController@attrEdit');
        $router->post('tmp/attr/del', 'TmpController@attrDel');
    });
    $router->group(['prefix'=>'my/address'], function () use ($router) {
        $router->post('list', 'AddressController@index');
        $router->post('modify', 'AddressController@modify');
        $router->post('todefault', 'AddressController@toDefault');
        $router->post('del', 'AddressController@del');
    });
    $router->group(['prefix'=>'yw-mall', 'namespace'=>'Ywmall'], function () use ($router) {
        $router->post('shop/list', 'ShopController@index');
        $router->post('shop/modify', 'ShopController@modify');
        $router->post('shop/del', 'ShopController@del');
        $router->post('goods/list', 'GoodsController@index');
        $router->post('goods/one', 'GoodsController@one');
        $router->post('goods/onebyid', 'GoodsController@onebyid');
        $router->post('goods/add', 'GoodsController@add');
        $router->post('goods/modify', 'GoodsController@modify');
        $router->post('goods/img/upload', 'GoodsController@imgUpload');
        $router->post('goods/cate/list', 'GoodsController@cateList');
        $router->post('goods/cate/edit', 'GoodsController@cateEdit');
        $router->post('goods/attr/list', 'GoodsController@attrList');
        $router->post('goods/attr/edit', 'GoodsController@attrEdit');
        $router->post('goods/attr/del', 'GoodsController@attrDel');
        $router->post('gorder/index', 'GorderController@index');
        $router->post('gorder/add', 'GorderController@add');
        $router->post('gorder/del', 'GorderController@del');
        $router->post('fuwu/list', 'FuwuController@index');
//        $router->post('fuwu/one', 'FuwuController@one');
        $router->post('fuwu/onebyid', 'FuwuController@onebyid');
//        $router->post('fuwu/add', 'FuwuController@add');
//        $router->post('fuwu/modify', 'FuwuController@modify');
//        $router->post('fuwu/img/upload', 'FuwuController@imgUpload');
//        $router->post('fuwu/cate/list', 'FuwuController@cateList');
//        $router->post('fuwu/cate/edit', 'FuwuController@cateEdit');
//        $router->post('fuwu/attr/list', 'FuwuController@attrList');
//        $router->post('fuwu/attr/edit', 'FuwuController@attrEdit');
//        $router->post('fuwu/attr/del', 'FuwuController@attrDel');
        $router->post('fworder/index', 'FworderController@index');
        $router->post('fworder/add', 'FworderController@add');
        $router->post('fworder/del', 'FworderController@del');
    });
});